function meta_analysis_template(proj_meta,cur_site,cell,pl_cells)

if max(pl_cells)~=cell
    pl=find(pl_cells>=cell,1,'first');
    if pl>1
        corr_cell=cell-pl_cells(pl-1);
    else
        corr_cell=cell;
    end
else
    pl=length(pl_cells);
    corr_cell=cell-pl_cells(pl-1);
end

% dims=size(proj_meta(cur_site).rd(1,1).template);

% bitmaps=zeros(dims(1),dims(2),size(proj_meta(cur_site).rd,2));
% for tnd=1:size(proj_meta(cur_site).rd,2)
%     cur_map=zeros(dims(1),dims(2));
%     cur_map(proj_meta(cur_site).rd(pl,tnd).ROIinfo(corr_cell).indices)=1;
%     bitmaps(:,:,tnd)=cur_map;
% end

pos=[];
col_range=[];
row_range=[];
for tnd=1:size(proj_meta(cur_site).rd,2)
    cur_pos=[min(proj_meta(cur_site).rd(pl,tnd).ROIinfo(corr_cell).indices) max(proj_meta(cur_site).rd(pl,tnd).ROIinfo(corr_cell).indices)];
    col_range(tnd,:)=[max([1 ceil(cur_pos(1)/400)-100]) min([750 ceil(cur_pos(2)/400)+100])];
    row_range(tnd,:)=[max([1 (cur_pos(1)-(floor(cur_pos(1)/400)*400))-54]) min([400 (cur_pos(2)-(floor(cur_pos(2)/400)*400))+54])];
%     pos(tnd,:)=[(cur_pos(1)-(400*floor(cur_pos(1)/400)))-row_range(tnd,1) (max([1 floor(cur_pos(1)/400)-5]))-col_range(tnd,1)];
    mid_ind=proj_meta(cur_site).rd(pl,tnd).ROIinfo(corr_cell).indices(ceil(length(proj_meta(cur_site).rd(pl,tnd).ROIinfo(corr_cell).indices)/2));
    pos(tnd,:)=[(mid_ind-(400*floor(mid_ind/400)))-row_range(tnd,1) (max([1 floor(mid_ind/400)-5]))-col_range(tnd,1)];
end

figure(40);
clf
set(gcf,'pos',[11         112        3786         527])
% set(gcf,'pos',[4091        -398         328         239])
for tnd=1:size(proj_meta(cur_site).rd,2)
    hold on
    subplot(1,size(proj_meta(cur_site).rd,2),tnd)
    imagesc(proj_meta(cur_site).rd(pl,tnd).template(row_range(tnd,1):row_range(tnd,2),col_range(tnd,1):col_range(tnd,2),:))
%     set(gca,'clim',[50 6000])
    colormap gray
    axis off
    box off
    text([pos(tnd,2) pos(tnd,2)],[pos(tnd,1) pos(tnd,1)],num2str(corr_cell),'fontsize',7,'col','r')
%     subplot(size(proj_meta(cur_site).rd,2),2,tnd*2)
%     imagesc(bitmaps(:,:,tnd))
%     axis off
%     box off
end